// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import vuex from 'vuex'
import store from "./util/store";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
import http from "./util/http"
import qs from 'qs'
import moment from "moment";
import {config} from "shelljs";
Vue.config.productionTip = false

Vue.use(vuex)
Vue.prototype.$http=http
Vue.prototype.$qs=qs
Vue.prototype.$store=store
Vue.use(ElementUI)
Vue.use(moment)
router.beforeEach((to, form, next) => {
  let loginUser = sessionStorage.getItem("token");
  loginUser=qs.parse(loginUser)
  console.log(loginUser.uid)

  if (to.name == 'book' || to.name == 'register' ||to.name=='login' ||to.name=='activty' || to.name=='main' || loginUser.uid != null) {
    // 去登录或者是已经登录
    next()
  } else {
    // 未登录
    alert("请登录")
    next('/book')
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
